
//phương thức js liên quan đến màn hình amdin_product
function user_admin_product() {

    var ACT_ADD							= 10;
    var ACT_UPDATE = 11;
    var ACT_GET = 15;
	var ACT_DELETE = 12;
	var ACT_CHANGE_PAGE = 13;
	var ACT_SHOW_EDIT = 14;
    var _strPage = "admin_product.php";

    var NAME_COMBOBOX = 'combobox_add';
    var _num_element = 1;
    //số thứ tự element của câu hỏi đã được khởi tạo ban đầu tự động là 2
    var _num_element_answer = 2;
   
    /*Thêm mộ bộ element select và textbox để nhập tính năng*/
    this.addElementProperty = addElementProperty;
    function addElementProperty(parentID, sectionID) {

        strSect = core.getObject("txtSect").val();
        //if (typeof (strSect) == 'undefined' || strSect == null || strSect < 1) {
        if (strSect && strSect > 0) {
            strID = NAME_COMBOBOX + _num_element;
          
            _num_element++;
            //tạo element
            eSelect = core.createElementComboBox(strID);
            optionNew = document.createElement("option");
            optionNew.text = '--Chọn hoặc gõ--';
            optionNew.value = 'qp';
            eSelect.appendChild(optionNew);
            
    //        optionNew = document.createElement("option");
    //        optionNew.text = 'Quay phim';
    //        optionNew.value = 'qp';
    //        eSelect.appendChild(optionNew);
    //        
    //        optionNew = document.createElement("option");
    //        optionNew.text = '3G';
    //        optionNew.value = '3g';
    //        eSelect.appendChild(optionNew);
            
            eSelect.setAttribute("id", strID);
            eSelect.setAttribute("class", 'property-combobox');
            eTextBox = core.crateElementInput('textbox');
            eTextBox.setAttribute("id", strID + '_input');
            eTextBox.setAttribute("class", 'property-input');
            //tạo thẻ  div bao bọc 2 element
            var elementDiv = document.createElement("div");
            elementDiv.setAttribute("class", 'e-property');
            elementDiv.setAttribute("id", 'e-property'+strID);
            elementDiv.appendChild(eSelect);
            elementDiv.appendChild(eTextBox);

            objParent = core.getObject(parentID);
            objParent.append(elementDiv);
       

       
            var strRequest = "?isAJ=1&act=" + ACT_GET + "&sect=" + core.urlencode(strSect)+ "&num=" + core.urlencode(_num_element-1)+"&uptime="+core.getMilliseconds();
            //alert(strRequest);
            //alert('call');
            
            var ajax = new Ajax();
             //setTimeout(function(){
             ajax.SendRequestToServerWithCustomMsg('admin_property.php',strRequest, addElementProperty_OnCallBack, false, MSG_AJAX_FETCHING_VN);
             //},3000);
        }
        else {
            popDiv.alert('Chưa chọn ngành hàng.', SYSTEM_TITLE_ERROR, 1);
        }
       
    }

    function addElementProperty_OnCallBack(xmlHTTPRequest) {
    
        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);
                if (!core.headerProcessingArr(strRespond[0], Array(true, true, false))) {
                    // phải khởi tạo lại để tránh đóng popdiv addFavourite
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                else{
                 number = strRespond[1]['num'];
                if (parseInt(strRespond[1]['rs']) == 1) {
                   
                    //alert(strRespond[1]['num']);
                    //for(i=0;i<number;i++)
                    {
						core.getObject( NAME_COMBOBOX + number)[0].innerHTML = strRespond[1]['inf'];
                    }
                   
                }
                else {
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(strRespond[1]["inf"], SYSTEM_TITLE_ERROR, 1);
                }
               // for(i=0;i<number;i++)
                    {
                    //core.getObject( NAME_COMBOBOX + i;)[0].innerHTML = strRespond[1]['inf'];
                     //rebuid combobox
                    //alert(_strID);
                    $(function() {
                        $("#" + NAME_COMBOBOX + number).combobox();
                        $("#toggle").click(function() {
                            $("#" + NAME_COMBOBOX + number).toggle();
                        });
                    });
                    }
                   
                }
            }
        }
    }

    /*Thêm một căp input textbox để nhập hỏi đáp*/
     this.addElementfaq = addElementfaq;
    function addElementfaq(parentID) {
        //tạo element
        var elementLabel = document.createElement("h2");
        elementLabel.innerHTML ="Câu hỏi thứ "+_num_element_answer+":";
        
        eTextboxQuestion = core.createElementArea();
        eTextboxQuestion.setAttribute("class", 'question-input');
        eTextboxQuestion.setAttribute("style", 'width:100%;');
        eTextBoxAnswer = core.createElementArea();
        eTextBoxAnswer.setAttribute("class", 'answer-input');
        eTextBoxAnswer.setAttribute("id", 'cmt'+_num_element_answer);
       
        var elementScript = document.createElement("script");
        //tranh xoa the div nhug chua xoa instance
        var instance = CKEDITOR.instances['cmt'+_num_element_answer];
        if(instance)
        {
            CKEDITOR.remove(instance);
        }
        strScript = "CKEDITOR.replace( 'cmt"+_num_element_answer+"',{";
		strScript +="			filebrowserBrowseUrl : '/ckfinder/ckfinder.html',";
		strScript +="			filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?type=Images',";
		strScript +="			filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?type=Flash',";
		strScript +="			filebrowserUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',";
		strScript +="			filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',";
		strScript +="			filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'";
		strScript +="}";
		strScript +=");";
		elementScript.setAttribute("type","text/javascript");
					 elementScript.innerHTML =strScript;
					 
        //một một thẻ div bao dọc 2 element
        var elementDiv = document.createElement("div");
        elementDiv.setAttribute("class", 'e-faq');
        elementDiv.appendChild(elementLabel);
        elementDiv.appendChild(eTextboxQuestion);
        elementDiv.appendChild(eTextBoxAnswer);
        elementDiv.appendChild(elementScript);

        objParent = core.getObject(parentID);
        objParent.append(elementDiv);
         _num_element_answer +=1;
    }

    this.btnSave_OnClick = btnSave_OnClick;
    function btnSave_OnClick() {
        //lấy nội dung tiếng Anh tiếng Việt từ người dùng nhập vào
        var name = core.trim(core.getObject("txtName")[0].value);
        var manu = core.trim(core.getObject("txtManu")[0].value);
        var cat = core.trim(core.getObject("txtCat")[0].value);
		strError = '';
        // Check nội dung EN-VN
        if (name == "") {
            core.getObject("txtName")[0].focus();
            //popDiv.alert("Tên sản phẩm không thể rỗng.", SYSTEM_TITLE_ERROR, 1);
			strError += "<p>Tên sản phẩm không thể rỗng.</p>"
            //return;
        }
        else if (name.length > 255) {
        core.getObject("txtName")[0].focus();
            //popDiv = new PopDiv();
            //popDiv.init();
            //show fail
            //popDiv.alert("Tên sản phẩm quá dài!", SYSTEM_TITLE_ERROR, 1);
            //return;
			strError += "<p>Tên sản phẩm quá dài!</p>"
        }
       if($("#txtCat").val()=="0")
		{
			strError += "<p>Chưa chọn nhóm hàng!</p>"
	   }

	   if(strError!="")
	{
		popDiv.alert(strError, SYSTEM_TITLE_ERROR, 1);
            return;
	   }
        //alert(txtNameProperty);
        //return;
        //kiểm tra xem ngôn ngữ tiếng anh có đúng không mới cho submit lên server
        if (core.getObject("adddocmode")[0].value == ADD_MODE) {
            insertNew();
        }
        else {
            edit();
        }


    }

    this.edit = edit;
    function edit() {
     core.disableControl("btnOK", false);
        // Get All Parameters
        core.getObject("adddocmode")[0].value = EDIT_MODE;
        strID = core.getObject("txtID").val();
        strName = core.getObject("txtName").val();
        strManu = core.getObject("txtManu").val();
        strSect = core.getObject("txtSect").val();
        strCat = core.getObject("txtCat").val();
        strDes = core.getObject("txtDescription").val();
        strTree = _objCommon.getTree('tree_property');
        strHTMLTree = core.getObject("tree_html")[0].innerHTML;
        
        txtNameProperty = "";
        $(".ui-autocomplete-input").each(function() {
                 txtNameProperty += $(this).val() + STRING_SEPARATE;
        });
        
        txtValueProperty = "";
        $(".property-input").each(function() {
            txtValueProperty += $(this).val() + STRING_SEPARATE;
        });
        strProperty = txtNameProperty + STRING_SEPARATE_1 + txtValueProperty;

        txtQuestion = "";
        $(".question-input").each(function() {
        txtQuestion += $(this).val() + STRING_SEPARATE;
        });
        txtAnswer = "";
		var index = 1;
        $(".answer-input").each(function() {
        //txtAnswer += $(this).val() + STRING_SEPARATE;
		txtAnswer += CKEDITOR.instances["cmt"+index].getData()+ STRING_SEPARATE;
		index ++;
        });

        txtFAQ = txtQuestion + STRING_SEPARATE_1 + txtAnswer;

        strRequest = "?isAJ=1&act=" + ACT_UPDATE + "&id=" + core.urlencode(strID) 
        +"&name=" + core.urlencode(strName) + "&manu="
         + core.urlencode(strManu) + "&cat=" + core.urlencode(strCat) + "&sect=" + core.urlencode(strSect) + "&des=" + core.urlencode(strDes) + 
        "&tree=" + core.urlencode(strTree) + "&property=" + core.urlencode(strProperty) + "&faq=" + core.urlencode(txtFAQ) + "&tree_html=" + core.urlencode(strHTMLTree);
        //alert(strRequest);
        var ajax = new Ajax();
        ajax.SendRequestToServerWithCustomMsg(_strPage , strRequest, insertNew_OnCallBack, true, MSG_AJAX_FETCHING_VN);
    }

    function edit_OnCallBack(xmlHTTPRequest) {
        core.disableControl("btnOK", false);
        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);
                if (!core.headerProcessingArr(strRespond[0], Array(true, true, false))) {
                    // phải khởi tạo lại để tránh đóng popdiv addFavourite
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                if (parseInt(strRespond[1]['rs']) == 1) {
                    
                    showInfoBar('success', MSG_RES_OPERATION_SUCCESS);
                    //alert(strRespond[1]['sens']);
                    // Add Doc && clear field
                    showAddMode();
                    changePageProducts(core.getObject("txtPage").val());
                }
                else {
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(strRespond[1]["inf"], SYSTEM_TITLE_ERROR, 1);
                }
            }
        }
    }

    this.insertNew = insertNew;
    function insertNew() {
		
        core.disableControl("btnOK", false);
        // Get All Parameters
        core.getObject("adddocmode")[0].value = ADD_MODE;

        strName = core.getObject("txtName").val();
        strManu = core.getObject("txtManu").val();
        strSect = core.getObject("txtSect").val();
        strCat = core.getObject("txtCat").val();
        strDes = core.getObject("txtDescription").val();
        strTree = _objCommon.getTree('tree_property');
        strHTMLTree = core.getObject("tree_html")[0].innerHTML;
        txtNameProperty = "";
        $(".ui-autocomplete-input").each(function() {
                 txtNameProperty += $(this).val() + STRING_SEPARATE;
        });
        
        txtValueProperty = "";
        $(".property-input").each(function() {
            txtValueProperty += $(this).val() + STRING_SEPARATE;
        });
        strProperty = txtNameProperty + STRING_SEPARATE_1 + txtValueProperty;

        txtQuestion = "";
        $(".question-input").each(function() {
        txtQuestion += $(this).val() + STRING_SEPARATE;
        });
        txtAnswer = "";
		var index = 1;
        $(".answer-input").each(function() {
        //txtAnswer += $(this).val() + STRING_SEPARATE;
		txtAnswer += CKEDITOR.instances["cmt"+index].getData()+ STRING_SEPARATE;
		index ++;
        });

        txtFAQ = txtQuestion + STRING_SEPARATE_1 + txtAnswer;
        strRequest = "?isAJ=1&act=" + ACT_ADD + "&name=" + core.urlencode(strName) + "&manu="
        + core.urlencode(strManu) + "&cat=" + core.urlencode(strCat) + "&sect=" + core.urlencode(strSect) + "&des=" + core.urlencode(strDes) + 
        "&tree=" + core.urlencode(strTree) + "&property=" + core.urlencode(strProperty) + "&faq=" + core.urlencode(txtFAQ) + "&tree_html=" + core.urlencode(strHTMLTree); 
        var ajax = new Ajax();
        ajax.SendRequestToServerWithCustomMsg(_strPage , strRequest, insertNew_OnCallBack, true, MSG_AJAX_FETCHING_VN);
    }
    
    // add by ThanhDao
    function insertNew_OnCallBack(xmlHTTPRequest) {
        core.disableControl("btnOK", false);
        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);
                if (!core.headerProcessingArr(strRespond[0], Array(true, true, false))) {
                    // phải khởi tạo lại để tránh đóng popdiv addFavourite
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                if (parseInt(strRespond[1]['rs']) == 1) {
                    showInfoBar('success', MSG_RES_OPERATION_SUCCESS);
                    //alert(strRespond[1]['sens']);
                    // Add Doc && clear field
                    showAddMode();
                    changePageProducts(1);
                    
                }
                else  // Duplicate
                {
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(MSG_RES_OPERATION_FAIL +"<br>"+ strRespond[1]['info'], SYSTEM_TITLE_ERROR, 1);
                }
            }
        }
    }

   
    this.showAddMode = showAddMode;
    function showAddMode() {
        //reset so luong element property va faq duoc khoi tao
        _num_element_answer=2;
        _num_element = 3;
        core.disableControl("txtCat", 1);
        core.getObject("txtName")[0].value = "";
        core.getObject("urlImage")[0].value = "";
        core.getObject("txtManu")[0].selectedIndex=0;
        core.getObject("txtDescription")[0].value = "";
        core.getObject("txtSect")[0].selectedIndex=0;
        core.getObject("txtCat")[0].selectedIndex=0;
        core.getObject("adddocmode")[0].value = ADD_MODE;

        core.getObject("status-add")[0].innerHTML = 'Add mode';
        var index=0;
        $(".e-property").each(function() {
//            if(index<2)
//            {
//                $(this).find('.property-input').val('');

//                $(this).find('.ui-autocomplete-input').val('--Chọn hoặc gõ--');
//            }
//            else
            {
                $(this).remove();
            }
            index++;
        });
        
        
        index=0;
        $(".e-faq").each(function() {
            if(index<1)
            {
                $(this).find('.question-input').val('');
                CKEDITOR.instances["cmt" + (index + 1)].setData('');
            }
            else
            {
                $(this).remove();
            }
            index++;
        });
       
        
    }
    this.showEdit = showEdit;
    function showEdit(strID) {
        strRequest = "?isAJ=1&act=" + ACT_SHOW_EDIT + "&id=" + strID; ;
        var ajax = new Ajax(METHOD_GET);
        ajax.SendRequestToServerWithCustomMsg(_strPage + strRequest, null, showEdit_OnCallBack, true, MSG_AJAX_FETCHING_VN);

    }
    function showEdit_OnCallBack(xmlHTTPRequest) {

        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);
                if (!core.headerProcessingArr(strRespond[0], Array(true, true, false))) {
                    // phải khởi tạo lại để tránh đóng popdiv addFavourite
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                if (parseInt(strRespond[1]['rs']) == 1) {
                    showInfoBar('success', MSG_RES_OPERATION_SUCCESS);
                    //alert(strRespond[1]['sens']);
                    // Add Doc && clear field
                    core.getObject('txtID').val(strRespond[1]['id']);
                    core.getObject('txtName').val(strRespond[1]['name']);
                    core.getObject('txtManu').val(strRespond[1]['manu']);
                    core.getObject('txtSect').val(strRespond[1]['sect']);
                    core.getObject('txtDescription').val(strRespond[1]['des']);
                    core.disableControl('txtCat', 0);
                    
                    core.getObject('txtCat')[0].innerHTML = strRespond[1]['cat_html'];
                    setTimeout(function() {
                        core.getObject('txtCat').val(strRespond[1]['cat']);
                    }, 200);
                    core.getObject('upload_area')[0].innerHTML = strRespond[1]['image'];
                    if(strRespond[1]['tree_html'])
                    {
                    core.getObject('tree_html')[0].innerHTML = strRespond[1]['tree_html'];
                    }
                    
                    //init padding tree global_script
                    initTreeFunction();
                    
                    var strPro = strRespond[1]['property'];
                    var arrPro = strPro.split(STRING_SEPARATE_1);
                    var txtProperty = $(".property-input");
                    intCount = arrPro.length-1;
                    //alert(intCount);
                    for(i=0;i<intCount;i++)
                    {
                        //valPro =  arrPro[i].split(STRING_SEPARATE);
                        if (typeof (txtProperty[i]) == "undefined" || txtProperty[i] == null) {
                           addElementProperty("zone-properties");
                        }
                        else 
                        {
                           
                            //txtProperty[i].value = valPro[1];
                        }
                        
                    }
                    
                    var txtNameProperty = $(".ui-autocomplete-input");
                    txtProperty = $(".property-input");
                    for (i = 0; i < intCount; i++) {
                        pairProperty =  arrPro[i].split(STRING_SEPARATE);
                         if( txtProperty[i])
                        {
                        txtProperty[i].value = pairProperty[1];
                        }
                        if(txtNameProperty[i])
                        {
                        txtNameProperty[i].value = pairProperty[0];
                        }

                    }



                    var strFAQ = strRespond[1]['faq'];
                    var arrFAQ = strFAQ.split(STRING_SEPARATE_1);
                    var txtQuestion = $(".question-input");
                    intCount = arrFAQ.length-1;
                    for (i = 0; i < intCount; i++) {
                        //valPro =  arrPro[i].split(STRING_SEPARATE);
                        if (typeof (txtQuestion[i]) == "undefined" || txtQuestion[i] == null) {
                            addElementfaq("zone-faq");
                        }
                        else {

                            //txtProperty[i].value = valPro[1];
                        }

                    }


                    //var txtAnswer = $(".ui-autocomplete-input");
                    txtQuestion = $(".question-input");
                    for (i = 0; i < intCount; i++) {
                        pairFAQ = arrFAQ[i].split(STRING_SEPARATE);
                        $(txtQuestion[i]).val(pairFAQ[0]);
                        //txtNameProperty[i].value = pairProperty[0];
                        CKEDITOR.instances["cmt" + (i + 1)].setData(pairFAQ[1]);
                    }

                    core.getObject("adddocmode")[0].value = EDIT_MODE;
                    core.getObject("status-add")[0].innerHTML = 'Edit mode';

                }
                else  // Duplicate
                {
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                }
            }
        }
    }
    this.deleteDoc = deleteDoc;
    function deleteDoc(docid, currentRowId) {
        curRow = currentRowId;
        var enObj = core.getObject('en' + currentRowId);
        var vnObj = core.getObject('vn' + currentRowId);
        var arrArguments = [];

        // Get english and vietnamese sentences
        arrArguments[0] = buildDocHTMLOnDialog(enObj.text(), vnObj.text());

        // Build message
        strMessage = stringFormat(CONFIRM_DELETE_ADDED_DOC, arrArguments);

        // Show confirm message
        //var popDiv = new PopDiv();
        //popDiv.init();\
        parent.window.popDiv.childPop.alert(strMessage, SYSTEM_TITLE_ERROR, 2, "window.frames['popupDivIframe'].objPopupSentence.deleteDoc_OK()", "window.frames['popupDivIframe'].objPopupSentence.deleteDoc_Cancel()");
        //parent.window.popDiv.childPop.alert(strMessage, SYSTEM_TITLE_ERROR, 2, "objPopupSentence.deleteDoc_OK()", "objPopupSentence.deleteDoc_Cancel()");

        //dlgBox.showDialog(SYSTEM_TITLE_ERROR, strMessage, "deleteDoc_OK()", "deleteDoc_Cancel()", 1);

        core.getObject("did")[0].value = docid;
        core.getObject("adddocmode")[0].value = EDIT_MODE;
        // Cache URL. Nếu click OK sẽ thực thi request lên url này
        _cacheURL_pdoc = _strPage + "?isAJ=1&act=" + ACT_DELETE + "&did=" + docid + "&p=" + core.getObject("txtPage")[0].value;
    }
    this.deleteDoc_Cancel = deleteDoc_Cancel;
    function deleteDoc_Cancel() {
        core.getObject("adddocmode")[0].value = ADD_MODE;
    }
    this.deleteDoc_OK = deleteDoc_OK;
    function deleteDoc_OK() {
        // Prepare AJAX to remove selected doc from favorite list
        // disableLink("del" + _docid, true, "javascript:objPopupSentence.deleteDoc(\"" + _docid + "\",\"" + _curRow + "\");");
        var ajax = new Ajax(METHOD_GET);
        ajax.SendRequestToServerWithCustomMsg(_cacheURL_pdoc, null, deleteDoc_OnCallBack, true, MSG_AJAX_FETCHING_VN);
    }
    function deleteDoc_OnCallBack(xmlHTTPRequest) {
        //  disableLink("del" + _docid, false, "javascript:objPopupSentence.deleteDoc(\"" + _docid + "\",\"" + _curRow + "\");");

        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);

                if (!core.headerProcessingArr(strRespond[0], Array(true, true, false))) {
                    // phải khởi tạo lại để tránh đóng popdiv addFavourite
                    //var popDiv = new PopDiv();
                    //popDiv.init();
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                if (parseInt(strRespond[1]['rs']) == 1) {
                    parent.window.showInfoBar('success', strRespond[1]["inf"]);
                    //gán lại paging tránh trường hợp cận 2 trang xóa 1 cặp câu còn 1 trang nhưng pagin vẫn ghi 2
                    core.getObject("txtPage")[0].value = strRespond[1]["p"];
                    parent.window.popDiv.childPop.hide();
                    var currentRow = core.getObject(curRow);
                    var arrArguments = [];
                    arrArguments[0] = core.getObject('en' + curRow).text();
                    arrArguments[1] = core.getObject('vn' + curRow).text();
                    //                    if (document.all)    // For IE
                    //                    {
                    //                        arrArguments[0] = currentRow.cells[0].innerText;
                    //                        arrArguments[1] = currentRow.cells[1].innerText;
                    //                    }
                    //                    else {// For Mozilla Family
                    //                        arrArguments[0] = currentRow.cells[0].textContent;
                    //                        arrArguments[1] = currentRow.cells[1].textContent;
                    //                    }
                    if (arrArguments[0] == core.getObject("txtEnContent")[0].value && arrArguments[1] == core.getObject("txtVnContent")[0].value) {
                        core.getObject("txtEnContent")[0].value = "";
                        core.getObject("txtVnContent")[0].value = "";
                        core.getObject("txtDescription")[0].value = "";
                    }
                    core.getObject("txtEnContent")[0].focus();
                    core.getObject("divTitle")[0].innerHTML = "Thêm cặp câu";
                    core.getObject("adddocmode")[0].value = ADD_MODE;
                    //
                    core.getObject("divPopDoc")[0].innerHTML = strRespond[1]['sens'];
                    //changeAmount("span_nod_user", 3, -1);
                    //core.getParentObject("span_nod_user").children[0].innerHTML = parseInt(core.getParentObject("span_nod_user").children[0].innerHTML) - 1;
                    //
                    //khỏi tạo lại sự kiện từ file global-script.js
                    initTblSentences();
                    //khởi tạo lại tooltip user
                    initMembersContext();
                }
                else //if(parseInt(strRespond[3]) == -1)
                {
                    parent.window.popDiv.childPop.childPop.alert(strRespond[1]["inf"], SYSTEM_TITLE_ERROR, 1);
                    //showInfoBar('error', strRespond[1]["inf"]);
                    //showMessage(strRespond[4]);
                }
            }
        }
    }
    //chỉ khi chọn ngành hàng thì nhóm hàng mới load lên nhóm tương ứng và cho phép thao tác
    this.loadCatalogue = loadCatalogue;
    function loadCatalogue() {
        
        selIdx =  core.getObject("txtSect")[0].selectedIndex;
        sectionID = core.getObject("txtSect")[0].options[selIdx].value;
        _objCatalogue.getCatalogueBySection(sectionID);
        
    }


    /*
    *	Đổi trang
    */
    var p;
    this.changePageProducts = changePageProducts;
    function changePageProducts(intPage) {
        var strRequest = "?isAJ=1&act=" + ACT_CHANGE_PAGE + "&p=" + intPage + '&uptime=' + core.getMilliseconds();
        var ajax = new Ajax();
        p = intPage;
        ajax.SendRequestToServerWithCustomMsgCache(_strPage + strRequest, null, changePageProducts_OnCallBack, true, MSG_AJAX_SENDING_VN);
    }

    function changePageProducts_OnCallBack(xmlHTTPRequest) {

        if (xmlHTTPRequest.readyState == 4) {
            if (xmlHTTPRequest.status == 200) {
                var strRespond = core.parserXML(xmlHTTPRequest.responseText);

                if (!core.headerProcessingArr(strRespond[0], Array(true, false, false))) {
                    //show fail
                    popDiv.alert(MSG_RES_OPERATION_FAIL, SYSTEM_TITLE_ERROR, 1);
                    return;
                }
                if (parseInt(strRespond[1]["rs"]) == 1) {
                    showInfoBar('success', "Thao tác thành công.");

                    // alert(strRespond[1]["inf"]);
                    core.getObject('list-content').html(strRespond[1]["inf"]);
                    core.getObject("txtPage")[0].value = p;
                   

                }
            }
        }
    }

}

_objAdminProduct = new user_admin_product();